using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB{
    /// <summary>
    /// Strongly-typed collection for the VwUserBase class.
    /// </summary>
    [Serializable]
    public partial class VwUserBaseCollection : ReadOnlyList<VwUserBase, VwUserBaseCollection>
    {        
        public VwUserBaseCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_userBase view.
    /// </summary>
    [Serializable]
    public partial class VwUserBase : ReadOnlyRecord<VwUserBase>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_userBase", TableType.View, DataService.GetInstance("CXDB"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarUID = new TableSchema.TableColumn(schema);
                colvarUID.ColumnName = "uID";
                colvarUID.DataType = DbType.Int32;
                colvarUID.MaxLength = 0;
                colvarUID.AutoIncrement = false;
                colvarUID.IsNullable = false;
                colvarUID.IsPrimaryKey = false;
                colvarUID.IsForeignKey = false;
                colvarUID.IsReadOnly = false;
                
                schema.Columns.Add(colvarUID);
                
                TableSchema.TableColumn colvarUsername = new TableSchema.TableColumn(schema);
                colvarUsername.ColumnName = "username";
                colvarUsername.DataType = DbType.String;
                colvarUsername.MaxLength = 50;
                colvarUsername.AutoIncrement = false;
                colvarUsername.IsNullable = true;
                colvarUsername.IsPrimaryKey = false;
                colvarUsername.IsForeignKey = false;
                colvarUsername.IsReadOnly = false;
                
                schema.Columns.Add(colvarUsername);
                
                TableSchema.TableColumn colvarPassWD = new TableSchema.TableColumn(schema);
                colvarPassWD.ColumnName = "passWD";
                colvarPassWD.DataType = DbType.String;
                colvarPassWD.MaxLength = 64;
                colvarPassWD.AutoIncrement = false;
                colvarPassWD.IsNullable = true;
                colvarPassWD.IsPrimaryKey = false;
                colvarPassWD.IsForeignKey = false;
                colvarPassWD.IsReadOnly = false;
                
                schema.Columns.Add(colvarPassWD);
                
                TableSchema.TableColumn colvarDepid = new TableSchema.TableColumn(schema);
                colvarDepid.ColumnName = "DEPID";
                colvarDepid.DataType = DbType.Int32;
                colvarDepid.MaxLength = 0;
                colvarDepid.AutoIncrement = false;
                colvarDepid.IsNullable = true;
                colvarDepid.IsPrimaryKey = false;
                colvarDepid.IsForeignKey = false;
                colvarDepid.IsReadOnly = false;
                
                schema.Columns.Add(colvarDepid);
                
                TableSchema.TableColumn colvarLevelID = new TableSchema.TableColumn(schema);
                colvarLevelID.ColumnName = "LevelID";
                colvarLevelID.DataType = DbType.Int32;
                colvarLevelID.MaxLength = 0;
                colvarLevelID.AutoIncrement = false;
                colvarLevelID.IsNullable = true;
                colvarLevelID.IsPrimaryKey = false;
                colvarLevelID.IsForeignKey = false;
                colvarLevelID.IsReadOnly = false;
                
                schema.Columns.Add(colvarLevelID);
                
                TableSchema.TableColumn colvarSecurityNum = new TableSchema.TableColumn(schema);
                colvarSecurityNum.ColumnName = "SecurityNum";
                colvarSecurityNum.DataType = DbType.Int32;
                colvarSecurityNum.MaxLength = 0;
                colvarSecurityNum.AutoIncrement = false;
                colvarSecurityNum.IsNullable = true;
                colvarSecurityNum.IsPrimaryKey = false;
                colvarSecurityNum.IsForeignKey = false;
                colvarSecurityNum.IsReadOnly = false;
                
                schema.Columns.Add(colvarSecurityNum);
                
                TableSchema.TableColumn colvarDeptName = new TableSchema.TableColumn(schema);
                colvarDeptName.ColumnName = "DeptName";
                colvarDeptName.DataType = DbType.String;
                colvarDeptName.MaxLength = 50;
                colvarDeptName.AutoIncrement = false;
                colvarDeptName.IsNullable = true;
                colvarDeptName.IsPrimaryKey = false;
                colvarDeptName.IsForeignKey = false;
                colvarDeptName.IsReadOnly = false;
                
                schema.Columns.Add(colvarDeptName);
                
                TableSchema.TableColumn colvarStatus = new TableSchema.TableColumn(schema);
                colvarStatus.ColumnName = "status";
                colvarStatus.DataType = DbType.Int32;
                colvarStatus.MaxLength = 0;
                colvarStatus.AutoIncrement = false;
                colvarStatus.IsNullable = true;
                colvarStatus.IsPrimaryKey = false;
                colvarStatus.IsForeignKey = false;
                colvarStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarStatus);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["CXDB"].AddSchema("vw_userBase",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public VwUserBase()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public VwUserBase(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public VwUserBase(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public VwUserBase(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("UID")]
        [Bindable(true)]
        public int UID 
	    {
		    get
		    {
			    return GetColumnValue<int>("uID");
		    }
            set 
		    {
			    SetColumnValue("uID", value);
            }
        }
	      
        [XmlAttribute("Username")]
        [Bindable(true)]
        public string Username 
	    {
		    get
		    {
			    return GetColumnValue<string>("username");
		    }
            set 
		    {
			    SetColumnValue("username", value);
            }
        }
	      
        [XmlAttribute("PassWD")]
        [Bindable(true)]
        public string PassWD 
	    {
		    get
		    {
			    return GetColumnValue<string>("passWD");
		    }
            set 
		    {
			    SetColumnValue("passWD", value);
            }
        }
	      
        [XmlAttribute("Depid")]
        [Bindable(true)]
        public int? Depid 
	    {
		    get
		    {
			    return GetColumnValue<int?>("DEPID");
		    }
            set 
		    {
			    SetColumnValue("DEPID", value);
            }
        }
	      
        [XmlAttribute("LevelID")]
        [Bindable(true)]
        public int? LevelID 
	    {
		    get
		    {
			    return GetColumnValue<int?>("LevelID");
		    }
            set 
		    {
			    SetColumnValue("LevelID", value);
            }
        }
	      
        [XmlAttribute("SecurityNum")]
        [Bindable(true)]
        public int? SecurityNum 
	    {
		    get
		    {
			    return GetColumnValue<int?>("SecurityNum");
		    }
            set 
		    {
			    SetColumnValue("SecurityNum", value);
            }
        }
	      
        [XmlAttribute("DeptName")]
        [Bindable(true)]
        public string DeptName 
	    {
		    get
		    {
			    return GetColumnValue<string>("DeptName");
		    }
            set 
		    {
			    SetColumnValue("DeptName", value);
            }
        }
	      
        [XmlAttribute("Status")]
        [Bindable(true)]
        public int? Status 
	    {
		    get
		    {
			    return GetColumnValue<int?>("status");
		    }
            set 
		    {
			    SetColumnValue("status", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string UID = @"uID";
            
            public static string Username = @"username";
            
            public static string PassWD = @"passWD";
            
            public static string Depid = @"DEPID";
            
            public static string LevelID = @"LevelID";
            
            public static string SecurityNum = @"SecurityNum";
            
            public static string DeptName = @"DeptName";
            
            public static string Status = @"status";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
